/**
 * @(#)XPWebEntryPoint.java        1.00 Nov 14, 2009
 *
 * Copyright (c) 2008 XProtean, Inc.
 * 461 S. Milpitas Blvd, Milpitas, CA, 95035, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * XProtean, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with XProtean Inc.
 *
 * gprasad      1.00    Nov 14, 2009     gprasad     Initial code
 */
package org.ql.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.BodyElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Frame;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import org.ql.client.framework.AppManager;
import org.ql.client.util.Log;

/**
 * Main entry point.
 *
 * @author gprasad
 */
public class XPWebEntryPoint implements EntryPoint {

    static {
        sop("------------------------------------------");
        sop("XPWebEntryPoint CLASS LOADED");
    }

    /**
     * Creates a new instance of XPWebEntryPoint
     */
    public XPWebEntryPoint() {
        sop("XPWebEntryPoint object created....");
    }

    /** 
     * The entry point method, called automatically by loading a module
     * that declares an implementing class as an entry-point
     */
    public void onModuleLoad() {
        AppManager.init();
        final Label label = new Label("Hello, GWT!!!");
        final Button button = new Button("Click me!");

        button.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                label.setVisible(!label.isVisible());
                Log.out(":" + AppManager.getContent("telluride/register.html"));
            }
        });



        RootPanel.get().add(button);
        //        RootPanel.get().add(label);
    }

    public static void sop(Object o) {
        System.out.println(": " + o);
    }

    private void rd() {
        RootPanel appContentFrame = RootPanel.get("appContent");
        RootPanel rdDiv = RootPanel.get("rd1");

        sop("appContentFrame: " + appContentFrame);
        sop("rdDiv: " + rdDiv);
        Element iFrameElement = appContentFrame.getBodyElement();
        sop("iFrameElement: " + iFrameElement);
        sop("getElementsByTagName: " + iFrameElement.getElementsByTagName("rd1").getItem(0));
        sop("Ifrom owner : " + iFrameElement.getOwnerDocument().getTitle());
        sop("Ifrom owner : " + iFrameElement.getOwnerDocument().getElementById(""));
        Element divElement = iFrameElement.getOwnerDocument().getElementById("rd1");
        sop("divElement: " + divElement);
        RootPanel rp;
        RootPanel.get(":");
        Frame fr = new Frame();

    }

    private static void rd2() {
        RootPanel contentDiv = RootPanel.get("content");
        HTMLPanel html = new HTMLPanel("<DIV id='x1'>gg</DIV>");


        contentDiv.add(html);
        Button bt = new Button("ASdasdasdasds");
        html.add(bt, "x1");
        bt.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                Window.alert("Tahnka u veary mugbc");
            }
        });
    }
}
